package com.tw;

/**
 * Created by admin on 16/06/14.
 */
public class IsocelesTriangle {
    private int nrows;

    IsocelesTriangle() {
        nrows = 0;
    }

    public void ChangeNrows(int n) {
        nrows = n;
    }

    IsocelesTriangle(int n) {
        nrows = n;
    }

    public void generateTriangle(int verticalOffset) {
        int i;
        int j = 1;
        for (i = this.nrows; i > 0; i--, j += 2) {
            Row.generateHztEmptyRow(i - 1 + verticalOffset);
            Row.generateHztStarRow(j);
            System.out.print("\n");
        }
    }

    public void generateInvertedTriangle(int verticalOffset) {
        int i;
        int startingRowStars = 1;
        for (i = 1; i < this.nrows; i++) {
            startingRowStars += 2;
        }
        //startingRowStars -= 2;
        for (i = 0; i < this.nrows; i++, startingRowStars -= 2) {
            Row.generateHztEmptyRow(i + verticalOffset);
            Row.generateHztStarRow(startingRowStars);
            System.out.print("\n");
        }
    }
}
